﻿using System.Net;
using Swifter.RW;

namespace RpcHelper.Json
{
    internal class IPEndPointType : IValueInterface<IPEndPoint>
    {
        public IPEndPoint ReadValue(IValueReader valueReader)
        {
            string val = valueReader.ReadString();
            if (val.IsNull())
            {
                return null;
            }
            return IPEndPoint.Parse(val);
        }

        public void WriteValue(IValueWriter valueWriter, IPEndPoint value)
        {
            if (value != null)
            {
                valueWriter.WriteString(value.ToString());
            }
        }
    }
}
